package huiji;

import java.awt.*;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 主角飞机
 */
public class HeroPlane extends AttackObj {
    static public HeroPlane hero = new HeroPlane();
    static {
        hero.setImageList(Arrays.asList(
                new HuijiImage().setImageAndWH(ImageUtil.gainImage("hero0.png")),
                new HuijiImage().setImageAndWH(ImageUtil.gainImage("hero1.png"))
        ));
    }

    /**
     * 设置集合下标
     */
    static public void setHeroIndex(){
        hero.setIndex(HuijiJPanel.timeCount/2%2);//
    }

    @Override
    public Bullet createBullet() {
        final Bullet bullet =  new Bullet().setImageAndWH(ImageUtil.gainImage("bullet.png"));
        return bullet.setX(getX()+getImageList().get(getIndex()).getWidth()/2-bullet.width/2)
                .setY(getY());
    }



    /**
     * 跟随鼠标调整坐标
     */
    public void followMouse(int mouseX,int mouseY){
        this.x = mouseX -this.width/2;
        this.y = mouseY-this.height/2;
    }
    /**
     * 跟随鼠标调整坐标
     */
    public void batchFollowMouse(int mouseX,int mouseY){
        final HuijiImage image = this.getImageList().get(this.index);
        this.x = mouseX -image.getWidth()/2;//this.width/2;
        this.y = mouseY-image.getHeight()/2;
    }
}
